import os
import pathlib
import sys

root_path = str(pathlib.Path(os.path.abspath(__file__)).parent.parent.parent)
sys.path.append(root_path)

from sklearn.cluster import KMeans
from ml_utils.config.base_config import *
from ml_utils.model.grid_search import grid_search_cluster


# def model(x, params):
#     best_params = grid_search_cluster(x, KMeans(), params)
#     n_clusters = best_params['n_clusters']
#     cluster = KMeans(n_clusters=n_clusters, random_state=random_state)
#     return cluster

def model(best_params, n_clusters):
    # best_params = grid_search_cluster(x, KMeans(), params)
    if n_clusters:
        cluster = KMeans(n_clusters=n_clusters, random_state=random_state)
    else:
        n_clusters = best_params['n_clusters'][0]
        cluster = KMeans(n_clusters=n_clusters, random_state=random_state)
    return cluster

# def model(n_clusters):
#     # best_params = grid_search_cluster(x, KMeans(), params)
#     # n_clusters = best_params['n_clusters'][0]
#     cluster = KMeans(n_clusters=n_clusters, random_state=random_state)
#     return cluster
